// HistoricalRecordExporter.cpp: implementation of the HistoricalRecordExporter class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "kwclientcore.h"
#include "HistoricalRecordExporter.h"
#include "Client.h"

#include "MonitoringUnitLib\BaseCoalMineUnit.h"
#include "MonitoringUnitLib\BaseMonitoringUnit.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

HistoricalRecordExporter::HistoricalRecordExporter(RecordAckStruct * pRecordAckStruct, int nMaxNumOfRows, int nMaxNumOfCols):
RecordExporter(pRecordAckStruct, nMaxNumOfRows, nMaxNumOfCols)
{

}

HistoricalRecordExporter::~HistoricalRecordExporter()
{

}

void HistoricalRecordExporter::GetRecordString(long nCoalMineId, const CString& strMonUnitId, RecordItem * pRecordItem, CString& strTime, CString& strData) const
{
  BaseCoalMineUnit * pCoalMineUnit;
  BaseMonitoringUnit * pMonitoringUnit;
  Client::Instance()->GetCoalMineUnitAndMonUnitById(nCoalMineId, strMonUnitId, pCoalMineUnit, pMonitoringUnit);
  if (pCoalMineUnit && pMonitoringUnit)
  {
    pMonitoringUnit->GetRealtimeRecordString(RealtimeRecord(*pRecordItem), strTime, strData);
  }
}

void HistoricalRecordExporter::GetMonUnitString(long nCoalMineId, const CString& strMonUnitId, CString& str) const
{
  BaseCoalMineUnit * pCoalMineUnit;
  BaseMonitoringUnit * pMonitoringUnit;
  Client::Instance()->GetCoalMineUnitAndMonUnitById(nCoalMineId, strMonUnitId, pCoalMineUnit, pMonitoringUnit);
  if (pCoalMineUnit && pMonitoringUnit)
  {
    str.Format("%s %s %s", pCoalMineUnit->GetName(), pMonitoringUnit->GetId(), pMonitoringUnit->GetName());
  }
}
